package main

import (
	"fmt"
	"sync"
)

func main() {
	var group sync.WaitGroup
	var sm sync.Map

	group.Add(10)

	for i := 0; i < 10; i++ {
		go func(id int) {
			// 写操作
			for j := 0; j < 100; j++ {
				sm.Store("helloworld", j)
			}

			// 读操作
			for j := 0; j < 10; j++ {
				if value, ok := sm.Load("helloworld"); ok {
					fmt.Printf("Goroutine %d: %d\n", id, value)
				}
			}

			group.Done()
		}(i)
	}
	group.Wait()
}
